﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Text;
using System.Collections;
using NS.BLL.Systems;
using NS.Model.Systems;
using NS.Utilities;
using BLL;
using Model;

public partial class Platform_UaerComSet : System.Web.UI.Page
{
    private long UserID = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        UserID = long.Parse(Request.QueryString["UserID"]);

        if (!IsPostBack)
        {
            GridBind1();
        }
    }

    public void GridBind2()
    {
        FGridView2.DataSource = CommuntyService.GetAllCommunty(txtName.Text.Trim());
        FGridView2.DataBind();
    }
    public void GridBind1()
    {
        FGridView1.DataSource = UaerComService.GetAllUaerCom(UserID);
        FGridView1.DataBind();
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        GridBind2();
    }

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string ID = ((Button)sender).CommandArgument.ToString();
        UaerCom Model = new UaerCom();
        Model.UserID = UserID;
        Model.CommuntyID = long.Parse(ID);
        if (UaerComService.AddUaerCom(Model) > 0)
        {
            GridBind1();
        }
        else
        {
            MessageBox.ShowError(this, "添加，请稍后重试！");
        }
    }

    protected void btnDel_Click(object sender, EventArgs e)
    {
        string ID = ((Button)sender).CommandArgument.ToString();
        if (UaerComService.DeleteUaerComById(int.Parse(ID)) > 0)
        {
            GridBind1();
        }
        else
        {
            MessageBox.ShowError(this, "删除失败，请稍后重试！");
        }
    }
}